package myJs.admin.detailInfo

import myJs.CpLayer
import myJs.admin.Admin
import myJs.admin.changePassword.ChangePassword
import myJs.api.Api
import myJs.cps.Style
import myJs.myPkg.{ReactRouterDOM, layer}
import myJs.tool.Tool
import org.scalajs.dom.{URLSearchParams, document}
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits._
import shared.pojo.Pojo.{AdminData, EmailData}
import slinky.core.FunctionalComponent
import slinky.core.annotations.react
import slinky.core.facade.Hooks.{useEffect, useState}
import slinky.web.html._

@react object Cp {

  val curPage = DetailInfo

  type Props = Unit

  val component = FunctionalComponent[Props] { props =>

    val (admin, setAdmin) = useState(AdminData())
    object FTool {


    }

    useEffect(() => {
      Api.admin.detailInfo.map { curAdmin =>
        setAdmin(curAdmin)
      }

    }, List()
    )

    CpLayer(title = curPage.titleStr)(
      div(className := "page-content",
        div(className := "page-bar",
          ul(className := "page-breadcrumb",
            li(
              i(className := "fa fa-user"), " ",
              a(href := "#", "账户信息")
            )
          )
        ),

        div(className := "row-fluid",
          div(className := "row",
            div(className := "col-md-12 col-sm-12",
              div(className := "portlet blue-madison box",
                div(className := "portlet-title",
                  div(className := "caption",
                    "账户信息"
                  )
                ),
                div(className := "portlet-body",
                  form(className := "form-horizontal", style := Style(marginTop = 30),
                    div(className := "form-group",
                      label(className := "control-label col-sm-2", "账号:"),
                      div(className := "col-sm-3",
                        p(className := "form-control-static", s"${admin.account}")
                      ),
                      label(className := "control-label col-sm-2", "密码:"),
                      div(className := "col-sm-3",
                        p(className := "form-control-static", s"******", "  ",
                          a(href := s"${ChangePassword.absolutePath}", "点击修改")
                        )
                      ),
                    ),
                    div(className := "form-group",
                      label(className := "control-label col-sm-2", "邮箱:"),
                      div(className := "col-sm-3",
                        p(className := "form-control-static",
                          span(style:=Style(paddingRight = 8),s"${admin.email} "),
                          a(href := s"${Admin.changeEmail.absolutePath}", " 点击修改")
                        )
                      ),
                    ),
                  )
                ),
              ),

            )

          )
        )
      )
    )

  }

}
